<?php
class Message_RestController extends Ac_Rest_Controller
{

    public function indexAction() {
        $page = empty($_GET['start']) ? 1 : $_GET['start'];
        $per_page = 10;


        $list = Model_User::all()->sort(array('pos'=>1))->skip(($page-1) * $per_page)->limit($per_page);

        $tmp = array();
        foreach($list as $ele) {
            $tmp[] = array('id' => (string)$ele->_id, 'name' => $ele->name);
        }
        $this->_helper->json($tmp);
    }

    public function getAction() 
    {
        $id  = $this->_request->getParam('id');
        $ele = Model_User::one(array('ca' => new MongoId($id)));
       
        $tmp = array('id' => (string)$ele->_id, 'name' => $ele->name);
        $this->_helper->json($tmp);
    }

    public function postAction() 
    {
        $id  = $this->_request->getParam('id');
        $listing = Model_Listing::find($id);

        $email   = $_POST['email'];
        $message = $_POST['message'];


    }
}

